<template>
	<el-drawer title="工作日志详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main>
				<el-main>
					<el-form-item label="日志标题" prop="title">{{form.title}}</el-form-item>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="日志日期" prop="diaryDay">{{form.diaryDay}}
							</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="日志类型" prop="diaryType">
								<el-tag v-if="form.diaryType=='1'">工作日志</el-tag>
								<el-tag v-if="form.diaryType=='2'">个人日志</el-tag>
							</el-form-item>
						</el-col>
					</el-row>
						<div v-html="form.content"></div>
					<el-form-item label="相关附件" v-if="form.attachId!=''">
						<attach-menu :attachIds="form.attachId" :roleFlag="form.attachRole" :preview="true"></attach-menu>
					</el-form-item>
					<el-form-item label="创建人"  style="margin-top: 10px;">
						<div style="width: 100%;">
							<el-avatar :src="form.avatar" size="small" style="margin-top: 5px;"></el-avatar>
							<span style="position: absolute;margin-left: 15px">{{form.userName}}</span>
							<span style="float: right">
								<div>
									<el-icon style="margin-right: 10px;"><el-icon-clock/></el-icon>{{form.createTime}}
								</div>
							</span>
						</div>
					</el-form-item>
				</el-main>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>
<script>
export default {
	name: 'Diary Details',
	data() {
		return {
			form: {
				diaryId: '',
				title: '',
				diaryDay: '',
				diaryType: '1',
				content: '',
				attachId: '',
				attachRole: '1',
				msgType: '',
				createTime:"",
				userName:"",
				avatar:"",
			},
			model:"read",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {
	},
	methods: {
		open(){
			this.visible = true;
			return this;
		},
		setData(data){
			this.form.diaryId=data.diaryId
			this.form.title =data.title
			this.form.diaryDay=data.diaryDay
			this.form.content = data.content
			this.form.diaryType = data.diaryType
			this.form.attachId=data.attachId
			this.form.attachRole=data.attachRole
		},
		async getMyDiaryById(data)
		{
			let res = await this.$API.office.diary.getMyDiaryById.get({diaryId:data});
			{
				if(res.code==200)
				{
					this.form.diaryId=res.data.diaryId
					this.form.title =res.data.title
					this.form.diaryDay=res.data.diaryDay
					this.form.content = res.data.content
					this.form.diaryType = res.data.diaryType
					this.form.attachId=res.data.attachId
					this.form.attachRole=res.data.attachRole
					this.form.userName = res.data.userName
					this.form.avatar = res.data.avatar
					this.form.createTime = res.data.createTime;
				}else
				{
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}

}
</script>

<style>
</style>
